In the diagram, triangles $ABC$ and $CBD$ are isosceles. The perimeter of $\triangle CBD$ is $19,$ the perimeter of $\triangle ABC$ is $20,$ and the length of $BD$ is $7.$ What is the length of $AB?$ [asy]

size(7cm);
defaultpen(fontsize(11));

pair b = (0, 0);
pair d = 7 * dir(-30);
pair a = 8 * dir(-140);
pair c = 6 * dir(-90);

draw(a--b--d--c--cycle);
draw(b--c);

label("$y^\circ$", a, 2 * (E + NE));
label("$y^\circ$", b, 2 * (S + SW));
label("$x^\circ$", b, 2 * (S + SE));
label("$x^\circ$", d, 2 * (2 * W));

label("$A$", a, W);
label("$B$", b, N);
label("$D$", d, E);
label("$C$", c, S);

[/asy]
Solution: In $\triangle ABC,$ $\angle ABC=\angle BAC,$ so $AC=BC.$

In $\triangle BCD,$ $\angle CBD=\angle CDB,$ so $CD=BC.$

Since the perimeter of $\triangle CBD$ is $19$ and $BD=7,$ then $7+BC+CD=19$ or $2(BC)=12$ or $BC=6.$

Since the perimeter of $\triangle ABC$ is $20,$ $BC=6,$ and $AC=BC,$ then $AB+6+6=20$ or $AB=8.$

So our final answer is $\boxed{8}.$